package com.atguigu04.other.exer;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.Constructor;
import java.util.Properties;

public class FruitTest {

    @Test
    public void test1() throws Exception {

        Properties properties = new Properties();
        FileInputStream inputStream = new FileInputStream("src/config.properties");

        properties.load(inputStream);

        Class<?> fruitName = Class.forName((String) properties.get("fruitName"));
        Constructor<?> declaredConstructor = fruitName.getDeclaredConstructor();
        declaredConstructor.setAccessible(true);
        Fruit o = (Fruit)declaredConstructor.newInstance();

        Juicer juicer = new Juicer();
        juicer.run(o);

    }
}
